package day09;

import java.util.Objects;

public class stringTools01 {
    public static void main(String[] args) {
        Student03 s1 = new Student03("张大彪", 25);
        Student03 s2 = new Student03("李云龙", 32);
        Student03 s3 = new Student03("李云龙", 32);
        System.out.println(s1.toString());
        System.out.println(s2.toString());
        System.out.println(s3.toString());
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        System.out.println(s3.hashCode());
        System.out.println(s1==s2);
        System.out.println(s2==s3);
        System.out.println(s2.equals(s3));//true

    }
}
class Student03{
    String name;
    int age;

    public Student03() {
    }

    public Student03(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student03{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student03 student03 = (Student03) o;
        return age == student03.age && Objects.equals(name, student03.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}